<?php

/**
 * LoginController
 *
 * @author
 * @version
 */

defined('URLPATH') || define('URLPATH','/');
defined('LOGINMODELS') || define('LOGINMODELS',dirname(__FILE__) . '/../models/');
class LoginController extends Zend_Controller_Action {
	/**
	 * The default action - show the login page
	 */
	public function init() {
		// $this->_response->setHeader('ssssddd');
	}
	public function loginAction() {
		$config = array(
		        'style' => array(
		                   'css' => "<link href='../../apppublic/mf/admin/css/admincp.css' rel='stylesheet' type='text/css' />"                   
		                   , 'jquery' => "<script type='text/javascript' src='../../apppublic/mf/admin/js/jquery-1.3.2.js'></script>"
		                   , 'formValidator' => array( "<link href='../../apppublic/mf/admin/js/formValidator/css/validationEngine.jquery.css' rel='stylesheet'  media='screen' type='text/css'  charset='utf-8'/>"
		                   , "<link href='../../apppublic/mf/admin/js/formValidator/css/template.css' rel='stylesheet'  media='screen' type='text/css'  charset='utf-8'/>"
		                   , "<script type='text/javascript' src='../../apppublic/mf/admin/js/formValidator/js/jquery.validationEngine.js'></script>"
		                   , "<script type='text/javascript' src='../../apppublic/mf/admin/js/formValidator/js/jquery.validationEngine-cn.js'></script>"
		                   )
		                   )

		                   );

		                   $action = $this->_request->getBaseUrl() . URLPATH . $this->_request->getControllerName() . URLPATH . 'check';
		                   $config['form']['action'] = &$action;
		                   $this->view->assign($config);
		                   echo $this->view->render('login/login.phtml');

		                   // TODO Auto-generated LoginController::loginAction() default action
	}
	public function checkAction() {
		if($this->_request->isPost()){
			/*
			 * auth username
			 */
			$user['post'] = $this->_request->getPost();
            //$user['post']['username'] = ;
			//require LOGINMODELS . 'LoginAuth.php';
			//$LoginAuth = new LoginAuth();
			/*
            $authAdapter = new Zend_Auth_Adapter_DbTable();

            $authAdapter->setTableName(MF_DB_PREFIX . 'users')
                        ->setIdentityColumn('u_username')
                        ->setCredentialColumn('u_password')
                        ->setIdentity($user['post']['username'])
                        ->setCredential($user['post']['password']);

			*/
          // $this->_forward('index','index');
           header("Location: http://www.zflocal.com/public/index/index/");
		}else{
			/*
			 *  return loginAction
			 */
			$this->_helper->redirector('login');

		}
			
			
	}

}

